{{define "title"}}资源索引 {{end}}
{{define "content"}}
<div class="row">
	<div class="col-md-9 col-sm-6">
		<div class="sep20"></div>

		<ol class="breadcrumb">
			<li><a href="/">首页</a></li>
			<li class="active">资源索引</li>
		</ol>
		<ul class="nav nav-tabs box_white" role="tablist">
			{{range .categories}}
			<li role="presentation" id="tb-{{.Catid}}" data-intro="{{.Intro}}"{{if eq $.curCatid .Catid}} class="active"{{end}}><a href="/resources/cat/{{.Catid}}">{{.Name}}</a></li>
			{{end}}
		</ul>
		<div class="box_white">
			<div class="desc">
				<i class="glyphicon glyphicon-star"></i> <span id="cat_intro"></span>
			</div>
			<div class="resources">
				{{with $root := .}}
				{{range $i, $resource := .resources}}
				<div class="resource">
					<div class="rinfo">
						<a class="avatar pull-right" href="/user/{{.user.Username}}"><img src="{{gravatar .user.Avatar .user.Email 48 $root.is_https}}" alt="{{.user.Username}}"></a>
						<a class="link-url" href="{{.url}}" target="_blank" data-id="{{.id}}">{{.title}}</a>
						{{if .host}}
						<span class="host">({{.host}})</span>
						{{end}}
						<p class="ino">
							<i class="glyphicon glyphicon-user"></i> <a class="a-pop-info" href="/user/{{.user.Username}}" title="{{.user.Username}}">{{.user.Username}}</a> 于
							<em><abbr class="timeago" title="{{.ctime}}"></abbr></em> 发布
						</p>
						<p class="edi">
							<a href="/resources/{{.id}}#commentForm">
								<i class="glyphicon glyphicon-comment"></i> {{if .cmtnum}} <b>{{.cmtnum}}</b> {{end}}评论
							</a>
							<span><i class="glyphicon glyphicon-heart"></i> <b>{{.likenum}}</b> 喜欢</span>
							<span><i class="glyphicon glyphicon-eye-open"></i> <b>{{.viewnum}}</b> 阅读</span>
						</p>
					</div>
				</div>

				{{if eq (mod $i 10) 3}}
					{{if $.pos_ad.feed}}
					<div>
						{{if eq $.pos_ad.feed.AdType 0}}
							{{noescape $.pos_ad.feed.Code}}
						{{end}}
					</div>
					{{end}}
				{{end}}

				{{else}}
				<p class="text-center">该分类暂时没有任何资源</p>
				{{end}}
				{{end}}
			</div>
			{{if .page}}
			<nav class="text-center"><ul class="pagination pagination-sm">{{.page}}</ul></nav>
			{{end}}
		</div>
	</div>
	<div class="col-md-3 col-sm-6">
		<div class="sep20"></div>

		{{include "common/my_info.html" .}}

		{{if .pos_ad.right1}}
		<div class="box_white sidebar" id="ad-right1">
			{{if eq .pos_ad.right1.AdType 0}}
				{{noescape .pos_ad.right1.Code}}
			{{end}}
		</div>
		{{end}}
		
		{{include "sidebar/view_rank.html" (parseJSON `{"rank_title":"今日阅读排行","objtype":2,"limit":10,"rank_type":"today"}`)}}
	
		{{include "sidebar/topic.html" .}}

		{{include "sidebar/view_rank.html" (parseJSON `{"rank_title":"一周阅读排行","objtype":2,"limit":10,"rank_type":"week"}`)}}

		{{if .pos_ad.right2}}
		<div class="box_white sidebar" id="ad-right2">
			{{if eq .pos_ad.right2.AdType 0}}
				{{noescape .pos_ad.right2.Code}}
			{{end}}
		</div>
		{{end}}
		
	</div>
</div>
{{end}}

{{define "css"}}
<style>
.nav-tabs>li:first-child>a,.nav-tabs>li:first-child>a:focus,.nav-tabs>li:first-child>a:hover {
	border-left: none;
}
.nav-tabs>li.active>a, .nav-tabs>li.active>a:hover, .nav-tabs>li.active>a:focus {
	color: #59BF74;
}
</style>
{{end}}

{{define "js"}}
<script type="text/javascript">
// 需要加载的侧边栏
SG.SIDE_BARS = [
	"/topics/recent",
	"/rank/view"
];

$(function(){
	var intro = $('#tb-'+{{.curCatid}}).data('intro');
	$('#cat_intro').html(intro);
});
</script>

{{if .pos_ad.right1}}
	{{if eq .pos_ad.right1.AdType 1}}
		{{noescape .pos_ad.right1.Code}}
	{{end}}
{{end}}

{{end}}
